<template>
	<a-config-provider prefix-cls="ss">
		<!-- 弹框登录 -->
		<ShotstackLoginModal :visible="loginVisible" @onClose="loginVisible = false" @loginCallback="loginCallback" />
	</a-config-provider>
</template>

<script>
	import {
		defineComponent,
		reactive,
		toRefs,
		computed,
		watch,
		toRaw,
		createVNode,
		ref,
		nextTick,
		onMounted,
		onUnmounted,
	} from "vue";
	import utils from "../../../common/utils/utils";
	import {
		useRoute,
		useRouter
	} from "vue-router";
	import {
		ConfigProvider
	} from 'ant-design-vue';
	export default defineComponent({
		name: "loginPage",
		setup() {
			// 配置主题色
			ConfigProvider.config({
				prefixCls: "ss",
				theme: {
					primaryColor: "#2878FF",
				},
			});
			
			const router = useRouter();
			const route = useRoute();
			const state = reactive({
				loginVisible: false,
				isLogin: false,
			});

			utils.checkLogin().then((isLogin) => {
				state.isLogin = isLogin;
				if (isLogin) {
					router.push("/workShotstack/home");
				} else {
					state.loginVisible = true;
				}
			});
			
			const loginCallback = () => {
				router.push("/workShotstack/home");
			};

			return {
				...toRefs(state),
				loginCallback
			};
		},
	});
</script>

<style lang="less" scoped>
</style>